package com.nineclock.sign.controller;

import com.nineclock.common.entity.PageResult;
import com.nineclock.common.entity.Result;
import com.nineclock.sign.SignInfoAttendanceControllerApi;
import com.nineclock.sign.dto.SignAllUserDTO;
import com.nineclock.sign.dto.SignDTO;
import com.nineclock.sign.dto.SignPCListDTO;
import com.nineclock.sign.service.SignInfoAttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SignInfoAttendanceController implements SignInfoAttendanceControllerApi {

    @Autowired
    SignInfoAttendanceService signInfoAttendanceService;

    @Override
    @GetMapping("/listSignAllUser")
    public Result<List<SignAllUserDTO>> pagingSignCurrentUserByMonth(@RequestParam("dateStr") String dateStr) {
        List<SignAllUserDTO> signDTOList = signInfoAttendanceService.pagingSignCurrentUserByMonth(dateStr);
        return Result.success(signDTOList);
    }

    /**
     * 查询详细信息
     * @param id
     * @return
     */
    @GetMapping("/getById")
    public Result<SignDTO> queryCompanyUserById(@RequestParam("id") Integer id){
        SignDTO signDTO = signInfoAttendanceService.queryCompanyUserById(id);
        return Result.success(signDTO);
    }

    @GetMapping("/sign")
    public Result<PageResult<SignPCListDTO> > querySignUserList(@RequestParam("endTime") String endTime, @RequestParam("page") String page, @RequestParam("pageSize") String pageSize, @RequestParam("startTime") String startTime){
        PageResult<SignPCListDTO> signAllUserDTO = signInfoAttendanceService.querySignUserList(endTime, page, pageSize, startTime);
        return Result.success(signAllUserDTO);
    }

}
